const path = require("path");
const htmlWebpackPlugin = require("html-webpack-plugin");
//暴露一个对象
module.exports = {
  //入口
  entry: "./src/index.ts",
  //出口
  output: {
    // path: __dirname + '/build',
    path: path.resolve(__dirname, "build"),
    //文件名  bundle 捆
    filename: "./js/bundle.js",
  },
  //模式
  mode: "development",
  //配置加载器
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: ["ts-loader"],
      },
      {
        test: /\.css$/,
        use: [
          'style-loader',
          'css-loader'
        ]
      }
    ],
  },
  //配置插件
  plugins: [
    new htmlWebpackPlugin({
      template: "./public/index.html",
    }),
  ],
  //解决  import x from './a'
  resolve: {
    //扩展名
    extensions: [".ts", ".tsx", ".js"],
  },
  //配置开发服务
  devServer: {
    port: 3000,
    hot: true,
    open: true,
  },
};
